package com.macaku.service.impl;

import com.macaku.component.AtomicEmailSender;
import com.macaku.component.po.Email;
import com.macaku.domain.dto.ModelMessage;
import com.macaku.service.EmailService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.io.File;
import java.util.function.Function;

/**
* @author 马拉圈
* @description 针对表【email】的数据库操作Service实现
* @createDate 2024-01-14 18:48:22
*/
@Service
@RequiredArgsConstructor
public class EmailServiceImpl implements EmailService{

    private final AtomicEmailSender atomicEmailSender;

    @Override
    public void sendSimpleMailMessage(Email email) {
        atomicEmailSender.sendSimpleMailMessage(email);
    }

    @Override
    public void sendMailWithFile(Email email, File... files) {
        atomicEmailSender.sendMailWithFile(email, files);
    }

    @Override
    public void sendModelMail(Email email, ModelMessage modelMessage) {
        atomicEmailSender.sendModelMail(email, "ModelMessage.html", modelMessage);
    }

    @Override
    public String selectNameByEmail(String email) {
        return email;
    }

    @Override
    public <T, R> void customizedSendEmail(Email email, String template, Function<T, R> function, File... file) {
        atomicEmailSender.customizedSendEmail(email, template, function, file);
    }

    @Override
    public void sendModelMail(Email email, ModelMessage modelMessage, File... attachment) {
        atomicEmailSender.sendModelMailWithFile(email, "ModelMessage.html", modelMessage, attachment);
    }

}




